package com.rs.listener;

import com.rs.entity.basic.DeviceStatus;
import com.rs.processor.CommandProcessor;
import com.rs.util.VehicleUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 指令开定时器执行指令监听
 *
 * @author zhouwz
 * @date 2020/9/13 8:40
 */
@Component
public class CommandListener {

    private final CommandProcessor commandProcessor;

    public CommandListener(CommandProcessor commandProcessor) {
        this.commandProcessor = commandProcessor;
    }

    /**
     * 实时状态监听处理
     */
    @Scheduled(fixedDelay = 100)
    public void commandHandler() {
        for (DeviceStatus deviceStatus : VehicleUtil.values()) {
            commandProcessor.singleVehicleHandler(deviceStatus);
        }
    }
}
